import React,{Component} from 'react';
// import store from './store.js'
import {connect} from 'react-redux';
class ReduxTest extends Component{
    // constructor(prop){
    //     super(prop)
    //     this.state = {
    //         count:0
    //     }
    // }
    // handleAdd(){
    //     this.setState({
    //         count: this.state.count +1
    //     })
    // }
    // handleMinus(){
    //     this.setState({
    //         count: this.state.count -1
    //     })
    // }
    render(){
        let { count, add, minus} = this.props
        return (
            <div>
                <div>
                    <button onClick={() => add()}>+</button>
                    <p>{count}</p>
                    <button onClick={() => minus()}>-</button>
                </div>
            </div>
        )
    }
}
const mapStateToProps = state=>{
    return {count:state}
}

const mapDispatchToProps = 
        {
        add:()=>({type:'add'}),
        minus: () => ({ type: 'minus' }),
    
}

export default connect(mapStateToProps, mapDispatchToProps)(ReduxTest)
// export default ReduxTest